<?php

class AppController extends Controller {
    var $helpers = array('Html','Ajax','Javascript');
	var $components      = array('Acl', 'Auth', 'RequestHandler','Cookie');
	
	
    
    function beforeFilter()
    {
		$this->Auth->authorize = 'actions';
        $this->Auth->loginAction = array('plugin'=>'pippoacl','controller' => 'users', 'action' => 'login');
        $this->Auth->logoutRedirect = array('plugin'=>'pippoacl','controller' => 'users', 'action' => 'login');
        $this->Auth->allowedActions = array('display','logout','login','register', 'confirm', 'forget', 'activate', 'reset','profile','switch_language');
		$this->Auth->userScope = array('User.active' => 1); //user needs to be active.
		
		
		 # Localization
        App::import('Core', 'l10n');
        $this->L10n = new L10n();
        # if language is already set in session, get that
        $language = $this->Session->read('Config.language');
		
        if(!$language) {
			$this->Session->write('Config.language', $language);
        }
        # now set the language
        $this->L10n->get($language);

        setlocale(LC_ALL, 
            substr($this->L10n->locale, 0, 3) .
            strtoupper(substr($this->L10n->locale, 3, 2)) . 
            '.' . $this->L10n->charset
        );
		
    }
}
?>